home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
stdlib1.exe
/
lha
/
OLDTEST.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-08-09
|
31KB
|
1,813 lines
;****************************************************************************
;
; T E S T S U I T E F O R
;
;
; R A N D Y H Y D E ' S S T A N D A R D
;
; L I B R A R Y F O R A S S E M B L Y
;
; L A N G U A G E P R O G R A M M E R S
;
;****************************************************************************
;
;
; Global variables go here:
;
dseg segment para public 'data'
i dw -4321
pi dd i
u dw 2345
pu dd u
l dd -1234567890
pl dd l
ul dd 987654321
pul dd ul
;
ps dd s
s db "Printf string",0
TestString0 db "This string gets printed by puts!",cr,lf,0
TestString1 db "This string gets used by the STRxxx Routines",cr,lf,0
TestString2 db "gets",0
TestString3 db "Hello there",0
TestString4 db "THIS STRING GETS USED BY THE STRXXX ROUTINES",cr,lf,0
TestString5 db "all lower case",cr,lf,0
TestString6 db "Clear out this string",0
StringSet1 db "Tabcdefghijklmnopqrst ",0
StringSet2 db "uvwxyz!",0
InsStrSrc db "Insert This",0
InsStrDest db "--><--",0
RevStr1 db "012345",0
RevStr2 db "0123456",0
RevStr3 db "1",0
RevStr4 db 0
buffer db 256 dup (?)
buffer2 db 256 dup (?)
sfstr1 db "1 -1 1 65000 100000 -100000 1 4000000000 0abc x",0
sfstr2 db "1, 2",0
hex1 db "12ab",0
int1 db "-12345",0
int2 db "65000",0
lint1 db "-2000000000",0
lint2 db "4000000000",0
i1 dw ?
i2 dw ?
u1 dw ?
u2 dw ?
l1 dd ?
l2 dd ?
ul1 dd ?
ul2 dd ?
h1 dw ?
c1 db ?
c2 db '!'
MemAvail dw ?
;
; Allocate some character sets down here
;
set charset, cs2, cs3, cs4
;
dseg ends
;
;
;
;
cseg segment para public 'code'
assume cs:cseg, ds:dseg
;
include stdlib.a
;
lesi macro adrs
mov di, seg adrs
mov es, di
lea di, adrs
endm
;
ldxi macro adrs
mov dx, seg adrs
lea si, adrs
endm
;
; Variables that wind up being used by the standard library routines.
; The MemInit routine uses "PSP" and "zzzzzzseg" labels. They must be
; present if you intend to use getenv, MemInit, malloc, and free.
;
;
public PSP
PSP dw ?
;
cr equ 13
lf equ 10
;
;
; Main is the main program. Program execution always begins here.
;
Main proc
mov cs:PSP, es ;Save pgm seg prefix
mov ax, seg dseg ;Set up the segment registers
mov ds, ax
mov es, ax
mov dx, 0 ;Allocate all available RAM.
MemInit
mov MemAvail, cx
printf
db "There are %x paragraphs of memory available."
db cr,lf,lf,0
dd MemAvail
;
;
;
;
;***************************************************************************
;
; Test the StrRev and StrRev2 routines here.
;
print
db "Testing StrRev:",cr,lf,0
lesi RevStr1
strrev
puts
putcr
strrev
puts
putcr
putcr
;
lesi RevStr2
strrev
puts
putcr
strrev
puts
putcr
putcr
;
lesi RevStr3
strrev
puts
putcr
strrev
puts
putcr
putcr
;
lesi RevStr4
strrev
puts
putcr
strrev
puts
putcr
;
;
print
db "Testing StrRev2:",cr,lf,0
lesi RevStr1
strrev2
puts
putcr
free
;
lesi RevStr2
strrev2
puts
putcr
free
;
lesi RevStr3
strrev2
puts
putcr
free
;
lesi RevStr4
strrev2
puts
putcr
free
putcr
;
;
;***************************************************************************
;
; Test the STRINS and STRDEL routines here.
;
print
db "Testing StrDel:",cr,lf,0
ldxi buffer
lesi InsStrDest
strcpy
mov ax, 2
mov cx, ax
strdel
puts
putcr
;
ldxi buffer
lesi InsStrDest
strcpy
mov ax, 20
mov cx, 2
strdel
puts
putcr
;
print
db "Testing StrDel2:",cr,lf,0
lesi InsStrDest
mov ax, 2
mov cx, ax
strdel2
puts
putcr
free
;
lesi InsStrDest
mov ax, 20
mov cx, 2
strdel2
puts
putcr
free
;
print
db "Testing StrInsl:",cr,lf,0
ldxi buffer
lesi InsStrDest
strcpy
;
mov cx, 3
strinsl
db "Hi there",0
puts
putcr
;
print
db "Testing StrIns2l:",cr,lf,0
lesi InsStrDest
mov cx, 3
strins2l
db "Ho ho ho!",0
puts
putcr
free
;
lesi InsStrDest
mov cx, 100
strins2l
db "and a bottle of rum!",cr,lf,0
puts
putcr
free
;
print
db "Testing STRINS2:",cr,lf,0
lesi InsStrDest
ldxi InsStrSrc
mov cx, 3
strins2
jnc GoodStrins2
print
db "Could not allocate memory for StrIns2",cr,lf,0
jmp short BadStrins2
;
GoodStrins2: puts
putcr
free
;
BadStrIns2: lesi InsStrDest
ldxi InsStrSrc
mov cx, 100
strins2
jnc GoodSI2
print
db "Strins2:memory allocation error",cr,lf,0
jmp short BSI2
;
GoodSI2: puts
putcr
free
;
BSI2: print
db "Testing STRINS:",cr,lf,0
lesi InsStrDest
ldxi InsStrSrc
mov cx, 3
strins
puts
putcr
lesi InsStrDest
ldxi InsStrSrc
mov cx, 100
strins
puts
putcr
;
;
;***************************************************************************
;
; Test the character set routines down here:
;
print
db "Testing RangeSet:",cr,lf,0
mov al, 'A'
mov ah, 'F'
lesi CharSet
rangeset
print
db "Chars in set: ",0
call PrintSet
;
print
db cr,lf,lf,"Testing addstr, addstrl:",cr,lf,0
lesi cs2
ldxi StringSet2
addstr
addstrl
db "aAbBcCdDeEfF",0
print
db "Chars in set: ",0
call PrintSet
;
print
db cr,lf,lf,"Testing rmvstr, rmvstrl:",cr,lf,0
lesi cs2
ldxi StringSet2
rmvstr
rmvstrl
db "ABCDEF",0
print
db "Chars in set: ",0
call PrintSet
;
print
db cr,lf,lf,"Testing addchar/rmvchar:",cr,lf,0
lesi cs2
mov al, 'A'
addchar
mov al, 'a'
rmvchar
print
db "Chars in set: ",0
call PrintSet
;
print
db cr,lf,lf,"Testing emptyset:",cr,lf,0
emptyset
print
db "Chars in set: ",0
call PrintSet
;
print
db cr,lf,lf,"Testing member:",cr,lf,0
addstrl
db "ABCDEF",0
mov al, 'A'
member
jne NotInSet1
print
db "A was not in the set",0
jmp short NIS1
;
NotInSet1: print
db "A is in the set",0
NIS1: putcr
mov al, "G"
member
jne NotInSet2
print
db "G is not in the set",0
jmp short NIS2
;
NotInSet2: print
db "G is in the set",0
NIS2: putcr
;
print
db cr,lf,lf,"Testing copyset:",cr,lf,0
mov dx, es
mov si, di
lesi cs3
copyset
print
db "Value in cs3: ",0
call Printset
;
print
db cr,lf,lf,"Testing unionset:",cr,lf,0
addstrl
db "ABCDEFuvwxyz",0
ldxi cs2
setunion
print
db "Chars in set: ",0
call Printset
;
print
db cr,lf,lf,"Testing set difference",cr,lf,0
ldxi cs2
setdifference
print
db "Chars in set: ",0
call PrintSet
;
;
;
;***************************************************************************
;
; Test the STRxxx routines here.
;
;
;*Strspan
;
print
db cr,lf,lf,"Testing strspan:",cr,lf,0
;
lesi TestString1
ldxi StringSet1
strspan
mov i1, cx
printf
db "TestString1 contains a character not found in "
db "StringSet1 at position %d\n\n",0
dd i1
;
;
;*Strspanl
;
print
db "Testing strspanl:",cr,lf,0
;
lesi TestString1
strspanl
db "Tabcdefghijklmnopqrst ",0
mov i1, cx
printf
db "TestString1 contains a character not found in "
db "the set at position %d\n\n",0
dd i1
;
;
;*Strcspan
;
print
db "Testing strcspan:",cr,lf,0
;
lesi TestString1
ldxi StringSet2
strcspan
mov i1, cx
printf
db "TestString1 contains a character found in "
db "StringSet2 at position %d\n\n",0
dd i1
;
;
;*Strcspanl
;
print
db "Testing strcspanl:",cr,lf,0
;
lesi TestString1
strcspanl
db "uvwxyz!",0
mov i1, cx
printf
db "TestString1 contains a character not found in "
db "the set at position %d\n\n",0
dd i1
;
;
;*Strset, Strset2
;
print
db "Testing Strset",cr,lf,0
;
lesi TestString6
mov al, '*'
strset
puts
;
;
print
db cr,lf,lf,"Testing StrSet2:",cr,lf,0
mov cx, 32
mov al, '#'
strset2
puts
free
putcr
put